extends 基础弹窗类

@onready var info_label =  $MarginContainer/VBoxContainer/Label
@onready var default_info_text = info_label.get_text()

var core = null

func _初始化(_data):
	刷新信息()

func 刷新信息():
	var player_cash = core.player_status["cash"]
	var player_bank_deposit_amount = core.player_status["bank_deposit_amount"]
	var new_info = default_info_text % [player_cash, player_bank_deposit_amount]
	info_label.set_text(new_info)
		
func _ready():
	core = GameCore
	core.存款变化.connect(刷新信息)
	core.现金变化.connect(刷新信息)
	var deposit_button = $MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/Button
	deposit_button.pressed.connect(func():self._setup_deposit_window())
	var withdraw_button = $MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/Button2
	withdraw_button.pressed.connect(func():self._setup_withdraw_window())
	var cancel_button = $MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/Button3
	cancel_button.pressed.connect(func():self._cancel())

func _setup_deposit_window():
	GameViewManager.打开弹窗("存钱")

func _setup_withdraw_window():
	GameViewManager.打开弹窗("取钱")
	
func _cancel():
	关闭()
